self.addEventListener('message', (e) => {
  let { type, hours, minutes, seconds } = e.data
  if (type === 'start') {
    const intervalId = setInterval(() => {
      if (seconds === 59) {
        seconds = 0
        if (minutes === 59) {
          minutes = 0
          hours++
        } else {
          minutes++
        }
      } else {
        seconds++
      }
      self.postMessage({ hours, minutes, seconds })
    }, 1000)
    self.addEventListener('message', (e) => {
      if (e.data.type === 'stop') {
        clearInterval(intervalId) // 停止计时器
      }
    })
  }
})
